//  品牌管理模块接口
import request from '@/utils/request'
import type { TradeMarkResponseData, TradeMark } from './type';
enum API {
    // 获取已有品牌接口
    TRADEMARK_URL = '/admin/product/baseTrademark/',
    // 添加
    ADDTRADEMARK_URL = '/admin/product/baseTrademark/save',
    // 修改
    UPDATETRADEMARK_URL = '/admin/product/baseTrademark/update',
    // 删除
    DELETE_URL = '/admin/product/baseTrademark/remove/'
}

// 获取已有品牌的接口方法
export const hasTrademarkAPI = (page:number, limit:number) =>
request.get<any, TradeMarkResponseData>(API.TRADEMARK_URL + `${page}/${limit}`);

// 添加与修改
export const addOrUpdateTrademarkAPI = (data: TradeMark) => {
    if (data.id) { // 有id就是修改品牌
        return request.put<any, any>(API.UPDATETRADEMARK_URL, data)
    } else {
        return request.post<any, any>(API.ADDTRADEMARK_URL, data)
    }
}

// 删除品牌
export const DeleteTrademark = (id: any) => request.delete<any,any>(API.DELETE_URL + id)